<?php

/**
 * 异常处理类
 * @author bing.peng
 *
 */
class Exceptions {
	
	var $levels = array(
		E_ERROR				=>	'Error',
		E_WARNING			=>	'Warning',
		E_PARSE				=>	'Parsing Error',
		E_NOTICE			=>	'Notice',
		E_CORE_ERROR		=>	'Core Error',
		E_CORE_WARNING		=>	'Core Warning',
		E_COMPILE_ERROR		=>	'Compile Error',
		E_COMPILE_WARNING	=>	'Compile Warning',
		E_USER_ERROR		=>	'User Error',
		E_USER_WARNING		=>	'User Warning',
		E_USER_NOTICE		=>	'User Notice',
		E_STRICT			=>	'Runtime Notice'
	);
	

	function show_php_error($severity, $message, $filepath, $line) {
		$severity = ( ! isset($this->levels[$severity])) ? $severity : $this->levels[$severity];
		$heading = $severity . "&nbsp;-&nbsp;" . $message;
		$message = "Error on line $line in $filepath";
		$this->show_error($heading, $message);
	}
	
	function show_error($heading, $message) {
		$message = '<p>'.implode('</p><p>', ( ! is_array($message)) ? array($message) : $message).'</p>';
		
		$vars = array(
			'heading' => $heading,
			'message' => $message
		);
		extract($vars); 
		ob_start();
		include(EVAPATH . 'errors/error.php');
		$buffer = ob_get_contents();
		ob_end_clean();
		echo $buffer;
	}
}

?>